<?php
namespace app\index\model;

use think\Model;

class Book extends Model
{

    //设置完整的数据表(包含前缀)
    protected $table = 'think_book';

    protected $type = [
        'publish_time' => 'timestamp: Y-m-d',
    ];

    //开启自动写入时间戳
    protected $autoWriteTimestamp = true;

    //定义自动完成的属性
    protected $insert = ['status' => 1];

    //定义关联方法
    public function user()
    {
        return $this->belongsTo('User');
    }

}
